<template>
  <div class="focusOnTheUser">
    <van-tabs v-model="active" animated sticky title-active-color="#f57">
      <van-tab title="用户">
        <div class="follow-user" v-if="followList.length > 0">
          <div class="follow-item" v-for="(item, i) in followList" :key="i">
            <!-- 左边图片区域 -->
            <div class="follow-avatar">
              <img :src="item.avatar" alt="" />
            </div>
            <!-- 中间和右边区域 -->
            <div class="follow-content">
              <div class="user-info">
                <p class="name">{{ item.name }}</p>
                <p class="desc">{{ item.height }}cm {{ item.weight }}kg</p>
              </div>
              <div class="follow-btn" @click="unfollow(item)">
                <span>已关注</span>
              </div>
            </div>
          </div>
          <div class="follow-loading">没有更多了～</div>
        </div>
        <!-- 为空时 -->
        <div class="goodsNull" v-else>
          <div class="null-img">
            <img src="@/assets/image/follownull.png" alt="" />
            <p>Ta还没有关注任何人</p>
          </div>
        </div>
      </van-tab>
      <van-tab title="店铺">
        <!-- 为空时 -->
        <div class="goodsNull">
          <div class="null-img">
            <img src="@/assets/image/dianpunull.jpg" alt="" />
            <p>还没有关注任何店铺哦</p>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { mapMutations, mapState } from "vuex";
export default {
  data() {
    return {
      active: 0,
    };
  },
  computed: {
    ...mapState("m_user", ["followList"]),
  },
  methods: {
    ...mapMutations("m_user", ["delfollowList"]),
    unfollow(item) {
      this.$dialog
        .confirm({
          title: "确定不再关注了?",
        })
        .then(() => {
          // on confirm
          this.delfollowList(item);
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .van-tabs__line {
  background-color: #ff5577;
  bottom: 20px;
}
::v-deep .van-tabs__wrap {
  border-bottom: 1px solid #e5e5e5;
}
.focusOnTheUser {
}
.follow-user {
  .follow-item {
    display: flex;
    padding-left: 10px;

    .follow-avatar {
      width: 38px;
      height: 38px;
      margin: 8px 11px 0 0;
      img {
        border-radius: 50%;
        display: block;
        width: 100%;
      }
    }
    .follow-content {
      padding: 11px 0;
      border-bottom: 1px solid #e5e5e5;
      height: 100%;
      display: flex;
      align-items: center;
      box-pack: justify;
      justify-content: space-between;
      width: 100%;
      margin-right: 11px;
      .user-info {
        .name {
          font-size: 14px;
          font-weight: 700;
          color: #333;
        }
        .desc {
          margin-top: 1.5px;
          font-size: 12px;
          color: #999;
          width: 220px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
      .follow-btn {
        width: 60px;
        height: 26px;
        line-height: 26px;
        text-align: center;
        border-radius: 14px;
        font-size: 12px;
        color: #999;
        border: 1px solid #999;
      }
    }
  }
}
.follow-loading {
  width: 100%;
  text-align: center;
  margin: 10px auto;
  font-size: 12px;
  color: #666666;
}
.goodsNull {
  margin-top: 10px;
  background-color: #fff;
  height: 100%;
  min-height: 300px;
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  .null-img {
    width: 257px;
  }
  img {
    width: 100%;
    border: none;
    vertical-align: middle;
    margin-bottom: 15px;
  }
  p {
    font-size: 16px;
    color: #666666;
  }
}
</style>